--[[ 编码: JX-17-14 名称: 计划盘点容器-创建盘点出库作业 作者:HAN 日期:2025-1-29 级别:项目 函数: CreateStocktakingOutOperation 功能: -- 如果计划盘点容器的盘点方法是自动搬运,需要创建一个搬运作业 更改记录: --]] wms_op = require( "wms_operation" ) wms_wh = require( "wms_wh" ) jx_base= require( "jx_base" ) function CreateStocktakingOutOperation ( strLuaDEID ) local nRet, strRetInfo local count_cntr = {} nRet, count_cntr = m3.GetCurEditDataObj( strLuaDEID ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【CP_Count_Container】对象属性失败!"..count_cntr ) end -- 如果盘点方式不是系统搬运直接返回 if ( count_cntr.method ~= 2 ) then lua.Warning( strLuaDEID, debug.getinfo(1), "计划盘点的容器号'"..count_cntr.cntr_code.."'的盘点方法="..count_cntr.method.."不能自动生成容器盘点出库!" ) return end if ( count_cntr.station == nil or count_cntr.station == '') then lua.Error( strLuaDEID, debug.getinfo(1), "计划盘点的出库容器中缺少盘点站台信息!" ) end -- 通过盘点站台获取出库终点货位 local station_attr nRet, station_attr = jx_base.Get_Station_ExtData( strLuaDEID, count_cntr.station ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), station_attr ) end local to_loc_code = lua.Get_StrAttrValue( station_attr.loc_code ) if ( to_loc_code == '' ) then lua.Error( strLuaDEID, debug.getinfo(1), "机台-"..count_cntr.station.." 常量中没有定义站台货位信息!" ) end local to_loc nRet, to_loc = wms_wh.GetLocInfo( to_loc_code ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '获取货位信息失败! '..to_loc ) end local operation = m3.AllocObject(strLuaDEID,"Operation") operation.start_wh_code = count_cntr.wh_code operation.start_area_code = count_cntr.area_code operation.start_loc_code = count_cntr.loc_code operation.end_wh_code = to_loc.wh_code operation.end_area_code = to_loc.area_code operation.end_loc_code = to_loc_code operation.op_type = wms_base.Get_nConst(strLuaDEID, "作业类型-出库") operation.op_def_name = "盘点出库" operation.cntr_code = count_cntr.cntr_code nRet, operation = m3.CreateDataObj( strLuaDEID, operation ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '创建【作业】失败!'..operation ) end -- 更新【计划盘点容器】对象属性 local strUpdateSql = "S_OUT_OP_NO = '"..operation.code.."'" strCondition = "S_ID = '"..count_cntr.id.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "CP_Count_Container", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【CP_Count_Container】信息失败!"..strRetInfo ) end end